package com.jml.单例模式;

public class 懒汉式解决并发问题001 {
    private static volatile 懒汉式解决并发问题001 INSTANCE;

    private 懒汉式解决并发问题001(){
        //可以避免反射破坏
        if(INSTANCE!=null){
            throw new RuntimeException("");
        }
    }

    public static 懒汉式解决并发问题001 getInstance(){
        if(INSTANCE == null){
            synchronized (Object.class){
                if(INSTANCE == null){
                    INSTANCE = new 懒汉式解决并发问题001();
                }
            }
        }
        return INSTANCE;
    }
}
